#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>

int main(int argv, char *argc[])
{
	DIR *dir;
	struct dirent *dirent;
	
	if(argv < 2)
	{
		printf("parameter error\r\n");
		return -1;
	}
	
	//打开目录
	dir = opendir(argc[1]);
	if(dir == NULL) 
	{
		perror("opendir");
		return -1;
	}
	
	//遍历目录
	for(; ; )
	{
		dirent = readdir(dir);
		if(dirent == NULL)
			break;
		printf("%s ", dirent->d_name);
//		printf("%ld ", telldir(dir));
	}
	printf("\r\n");
	//关闭目录
	closedir(dir);
	return 0;
}
